#include <iostream>
#include "SplayTree_class_vector.cpp"

using namespace std;

using namespace AlgoLib;

int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	SplayTree set = SplayTree();
	for (int i = 0; i < n; ++i)
	{
		char c;
		int x;
		cin >> ws >> c >> x;
		if (c == '+')
		{
			set.insert(x);
		}
		else if (c == '-')
		{
			set.erase(x);
		}
		else
		{
			cout << set.inTree(x) << '\n';
		}
		//cerr << c << " " << x << ":" << endl;
		//set.debug();
	}
	return 0;
}
